package com.pay.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Map;

public class SettleDayUtils {

	//private static Log log = LogFactory.getLog(SettleDayUtils.class);
	private static final String settleDayKey = "LFTSETTLEDAY";


	/**7点至23点30之间为秒到结算时间*/
	public static boolean beforeToday23_30_00(Date date) {
		try {
			Calendar dateCalendar = Calendar.getInstance();
			dateCalendar.setTime(date);

			Calendar startCalendar = Calendar.getInstance();
			Calendar endCalendar = Calendar.getInstance();
			startCalendar.set(Calendar.HOUR_OF_DAY, 7);
			startCalendar.set(Calendar.MINUTE, 0);
			startCalendar.set(Calendar.SECOND, 0);
			endCalendar.set(Calendar.HOUR_OF_DAY, 23);
			endCalendar.set(Calendar.MINUTE, 30);
			endCalendar.set(Calendar.SECOND, 0);

			if (dateCalendar.after(startCalendar)&&dateCalendar.before(endCalendar)) {
				return true ;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false ;
	}

	public static Map<String, String> getSettleDay(Map<String, String> res, Date date){
		SimpleDateFormat sdf= new SimpleDateFormat("MM.dd");
		String settleDay = sdf.format(date);
		res.put("settleDate", settleDay);
		Calendar now = Calendar.getInstance();
		now.setTime(new Date());
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		if(cal.get(Calendar.DAY_OF_MONTH)-now.get(Calendar.DAY_OF_MONTH)==1){
			res.put("settleWeek", "（明天）");
		}else if(cal.get(Calendar.DAY_OF_MONTH)-now.get(Calendar.DAY_OF_MONTH)==0){
			res.put("settleWeek", "（今天）");
		}else{
			res.put("settleWeek", "");
		}
		return res;
	}

	public static Map<String, String> getSettleDay(Map<String, String> res, Date date, String key){
		SimpleDateFormat sdf= new SimpleDateFormat("MM月dd日");
		Calendar now = Calendar.getInstance();
		now.setTime(new Date());
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		if(cal.get(Calendar.DAY_OF_MONTH)-now.get(Calendar.DAY_OF_MONTH)==1){
			res.put(key, "明日到账");
		}else if(cal.get(Calendar.DAY_OF_MONTH)-now.get(Calendar.DAY_OF_MONTH)==0){
			res.put(key, "今日到账");
		}else{
			String settleDay = sdf.format(date);
			res.put(key, settleDay + "到账");
		}
		return res;
	}


}
